<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>用户列表</title>
<meta name="description" content="这是一个 index 页面">
<meta name="keywords" content="index">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="../assets/i/favicon.png">
<link rel="aFple-touch-icon-precomposed"
	href="../assets/i/app-icon72x72@2x.png">
<meta name="apple-mobile-web-app-title" content="Amaze UI" />
<link rel="stylesheet" href="../assets/css/amazeui.min.css" />
<link rel="stylesheet" href="../assets/css/admin.css">
<link rel="stylesheet" type="text/css" href="../assets/js/layui/css/layui.css" />
    <style type="text/css">
    .page{float: right;}
    </style>

</head>
<body>
	<!--[if lte IE 9]><p class="browsehappy">升级你的浏览器吧！ <a href="http://se.360.cn/" target="_blank">升级浏览器</a>以获得更好的体验！</p>
<![endif]-->
</head>


<body>


	<div class="admin-biaogelist">

		<div class="listbiaoti am-cf">
			<ul class="am-icon-users">用户管理
			</ul>

			<dl class="am-icon-home" style="float: right;">
				当前位置： 首页 >
				<a href="#">用户详情列表</a>
			</dl>
		</div>



		<form class="am-form am-g">
			<table width="100%" id="tbody_admin"
				class="am-table am-table-bordered am-table-radius am-table-striped">
				<thead>
					<tr class="am-success">
						<th></th>
						<th class="table-id">ID</th>
						<th class="table-title">用户名</th>
						<th class="table-type">会员状态</th>
						<th class="table-author am-hide-sm-only">昵称</th>
						<th class="table-author am-hide-sm-only">性别</th>
						<th width="130px" class="table-set">操作</th>
					</tr>
				</thead>
				<tbody id="admin_List"></tbody>
			</table>
			<div class="page" id="page_order"></div>
			<hr/>
		</form>
	</div>
	<script id="template_admin" type="text/html">
						{{# for(var i=0;i<d.length;i++){ }}
							<tr>
							<td><input type="checkbox" /></td>

							<td><span id="id">{{ d[i].id }}</span></td>
							<td><span id="userName">{{ d[i].userName }}</span></td>
							<td><span id="vipId">{{ d[i].vipId==-1?"非会员":"会员" }}</span></td>
							<td class="am-hide-sm-only"><span id="nickName">{{ d[i].nickName }}</span></td>
							<td class="am-hide-sm-only"><span id="sex">{{ d[i].sex==1?"男":"女" }}</span></td>
							<td>


								<div class="am-btn-toolbar">
									<div class="am-btn-group am-btn-group-xs">
										 <a 
											class="am-btn am-btn-default am-btn-xs am-text-danger am-round" onclick="deleteAdmin({{ d[i].id }})"
											title="删除用户"><span class="am-icon-trash-o"></span></a>
									</div>
								</div>

							</td>
						</tr>

						{{# } }}
					</script>
	<script type="text/javascript" src="../assets/js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="../assets/js/root.js"></script>
	<script type="text/javascript" >
		var count = null;
		var size = null;
		$(function() {
			renderPage_admin();
	
		});
 
		//渲染分页元素
		function renderPage_admin() {
			//查询总数
			$.ajax({
				url : "/moviesMaven/user/getUserCount.htm",
				dataType : "json",
				success : function(data) {
					count = data//总数
					size = 3;//每页行数

					//渲染分页
					layui.use("laypage", function() {
						var laypage = layui.laypage;

						laypage.render({
							elem : "page_order",
							count : count,
							limit : size,
							theme : "#4287c2",
							jump : function(obj, first) {
								getData_admin(obj.curr, size);
							}
						});
					});
				}
			});
		}

		//获取用户数据
		function getData_admin(nowPage, size) {
			$.ajax({
				url : "/moviesMaven/user/getAllUserList.htm",
				data : {
					"nowPage" : nowPage,
					"size" : size
				},
				dataType : "json",
				success : function(data) {
					if (data.success) {
						//渲染页面
						renderData_admin(data.result);
					} else {
						layer.msg(data.message);
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.msg(textStatus + ":" + XMLHttpRequest.status);
				}
			});
		}

		//模板渲染订单列表
		function renderData_admin(data) {
			layui.use("laytpl", function() {
				var laytpl = layui.laytpl;

				var template_admin = $("#template_admin").html();
				laytpl(template_admin).render(data, function(html) {
					$("#admin_List").html(html);
				});
			});
		}

		
		
		
		//删除用户
		function deleteAdmin(id) {
			deleteUserList(id);
		}
	</script>
</body>
</html>